package com.business.controller.interfaced;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.business.service.interfaced.EntertainmentInManager;
import com.honour.service.interfaced.SortInManager;
import com.system.controller.base.BaseController;
import com.system.util.AppUtil;
import com.system.util.Const;
import com.system.util.FTPUtils;
import com.system.util.PageData;
import com.system.util.Tools;
import com.system.util.ToolsUtil;
import com.system.util.UpdImgUtils;

/**
 * 电商后台管理酒吧，KTV，美食，酒店接口
 * @Function 
 * @Author zhaozhenhua
 * @Date 2018年2月6日
 */
@Controller
@RequestMapping(value="entertainment")
public class EntertainmentController extends BaseController{
	
	@Resource(name="entertainmentInService")
	private EntertainmentInManager entertainmentInService;
	
	@Resource(name="sortinService")
	private SortInManager sortinService;
	
	/**
	 *   电商后台修改酒吧，KTV，美食，酒店的店铺信息
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月6日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="updentertainment")
	@ResponseBody
	public Object updEntertainment(MultipartHttpServletRequest mreq,HttpServletResponse resp,HttpServletRequest request,
			String CATEGORY_ID,String BUSINESS_ID,String SHOPSERV_ID,String SHOPSERVPARK,String SHOPSERVFOOD,String SHOPSERVWIFI,
			String SHOPSERVFITNESS,String SHOPSERVSWIM,String SHOPSERVPAY,String BRAND,String STYLE,int PRICE,String PHONE,
			String NAMES
			){
		logBefore(logger, "电商后台修改酒吧，KTV，美食，酒店的店铺信息");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		pd.put("CATEGORY_ID", CATEGORY_ID);
		pd.put("BUSINESS_ID", BUSINESS_ID);
		pd.put("SHOPSERV_ID", SHOPSERV_ID);
		pd.put("SHOPSERVPARK", SHOPSERVPARK);
		pd.put("SHOPSERVFOOD", SHOPSERVFOOD);
		pd.put("SHOPSERVWIFI", SHOPSERVWIFI);
		pd.put("SHOPSERVFITNESS", SHOPSERVFITNESS);
		pd.put("SHOPSERVSWIM", SHOPSERVSWIM);
		pd.put("SHOPSERVPAY", SHOPSERVPAY);
		pd.put("BRAND", BRAND);
		pd.put("STYLE", STYLE);
		pd.put("PRICE", PRICE);
		pd.put("PHONE", PHONE);
		pd.put("NAMES", NAMES);
		String result="00";
		System.out.println("pd1:"+pd);
		try{
			if(Tools.checkKey("UPDENTERTAINMENT", pd.getString("FKEY"))){	//检验请求key值是否合法
				//if(AppUtil.checkParam("addProduct", pd)){	//检查参数
				   String DETAILSIMGS="";  
				   String SHOWIMAGES="";
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					   //修改店铺服务
					   pd.put("SHOPSERVTYPE", "2");
					   if(pd.getString("SHOPSERV_ID")==null||"".equals(pd.getString("SHOPSERV_ID"))){
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   sortinService.saveShopServ(pd);
					   }else{
						   sortinService.updShopServ(pd);
					   }
					   //店铺首页单个图片处理
					   if(mreq.getFile("SHOWIMAGES")==null){}
					   else{
						    SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "sortimgs/sorthotelimgs/sorthotelshowimgs");
						    if(Tools.notEmpty(SHOWIMAGES)){
						    	UpdImgUtils.delImgMethod(pd, "SHOWIMAGES", "sortimgs/sorthotelimgs/sorthotelshowimgs");
						    	pd.put("SHOWIMAGES", SHOWIMAGES);
						    }
						}
					   //店铺详情图处理
					   DETAILSIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETAILSIMGS", "sortimgs/sorthotelimgs/hoteldetimgs");
					   if(Tools.notEmpty(DETAILSIMGS)){
						    UpdImgUtils.delImgMethod(pd, "DETAILSIMGS", "sortimgs/sorthotelimgs/hoteldetimgs");
							pd.put("DETAILSIMGS", DETAILSIMGS);
						}
					   if(Tools.isEmpty(SHOPSERV_ID)){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   pd.put("SHOPSERVTYPE", "2");
						   sortinService.saveShopServ(pd);
					   }else {
						   sortinService.updShopServ(pd);
					   }
					   entertainmentInService.updHotel(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					   //修改店铺服务  
					   pd.put("SHOPSERVTYPE", "1");
					   if(pd.getString("SHOPSERV_ID")==null||"".equals(pd.getString("SHOPSERV_ID"))){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   sortinService.saveShopServ(pd);
					   }else{
						   sortinService.updShopServ(pd);
					   }
					   //店铺首页单个图片处理
					   if(mreq.getFile("SHOWIMAGES")==null){}
					   else{
						    SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "sortimgs/sortfoodimgs/sortfoodshowimgs");
						    if(Tools.notEmpty(SHOWIMAGES)){
						    	UpdImgUtils.delImgMethod(pd, "SHOWIMAGES", "sortimgs/sortfoodimgs/sortfoodshowimgs");
						    	pd.put("SHOWIMAGES", SHOWIMAGES);
						    }
						}
					   //店铺详情图处理
					   DETAILSIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETAILSIMGS", "sortimgs/sortfoodimgs/fooddetimgs");
					   if(Tools.notEmpty(DETAILSIMGS)){
						   UpdImgUtils.delImgMethod(pd, "DETAILSIMGS", "sortimgs/sortfoodimgs/fooddetimgs");
							pd.put("DETAILSIMGS", DETAILSIMGS);
						}
					   if(Tools.isEmpty(SHOPSERV_ID)){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   pd.put("SHOPSERVTYPE", "1");
						   sortinService.saveShopServ(pd);
					   }else {
						   sortinService.updShopServ(pd);
					   }
					   System.out.println("pd2:"+pd);
					   entertainmentInService.updFood(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					   //修改店铺服务
					   pd.put("SHOPSERVTYPE", "3");
					   if(pd.getString("SHOPSERV_ID")==null||"".equals(pd.getString("SHOPSERV_ID"))){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   sortinService.saveShopServ(pd);
					   }else{
						   sortinService.updShopServ(pd);
					   }
					   //店铺首页单个图片处理
					   if(mreq.getFile("SHOWIMAGES")==null){}
					   else{
						    SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "sortimgs/sortktvimgs/sortktvshowimgs");
						    if(Tools.notEmpty(SHOWIMAGES)){
						    	UpdImgUtils.delImgMethod(pd, "SHOWIMAGES", "sortimgs/sortktvimgs/sortktvshowimgs");
						    	pd.put("SHOWIMAGES", SHOWIMAGES);
						    }
						}
					   //店铺详情图处理
					   DETAILSIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETAILSIMGS", "sortimgs/sortktvimgs/ktvdetimgs");
					   if(Tools.notEmpty(DETAILSIMGS)){
						   UpdImgUtils.delImgMethod(pd, "DETAILSIMGS", "sortimgs/sortktvimgs/ktvdetimgs");
							pd.put("DETAILSIMGS", DETAILSIMGS.substring(1));
						}
					   if(Tools.isEmpty(SHOPSERV_ID)){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   pd.put("SHOPSERVTYPE", "3");
						   sortinService.saveShopServ(pd);
					   }else {
						   sortinService.updShopServ(pd);
					   }
					   entertainmentInService.updKTV(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					   //修改店铺服务
					   pd.put("SHOPSERVTYPE", "4");
					   if(pd.getString("SHOPSERV_ID")==null||"".equals(pd.getString("SHOPSERV_ID"))){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   sortinService.saveShopServ(pd);
					   }else{
						   sortinService.updShopServ(pd);
					   }
					   //店铺首页单个图片处理
					   if(mreq.getFile("SHOWIMAGES")==null){}
					   else{
						    SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "sortimgs/sortbarimgs/sortbarshowimgs");
						    if(Tools.notEmpty(SHOWIMAGES)){
						    	UpdImgUtils.delImgMethod(pd, "SHOWIMAGES", "sortimgs/sortbarimgs/sortbarshowimgs");
						    	pd.put("SHOWIMAGES", SHOWIMAGES);
						    }
						}
					   //店铺详情图处理
					   DETAILSIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETAILSIMGS", "sortimgs/sortbarimgs/bardetimgs");
					   if(Tools.notEmpty(DETAILSIMGS)){
						   UpdImgUtils.delImgMethod(pd, "DETAILSIMGS", "sortimgs/sortbarimgs/bardetimgs");
							pd.put("DETAILSIMGS", DETAILSIMGS.substring(1));
						}
					   if(Tools.isEmpty(SHOPSERV_ID)){
						   pd.put("SHOPSERV_ID", this.getSnowId());
						   pd.put("SHOP_ID", pd.get("BUSINESS_ID"));
						   pd.put("SHOPSERVTYPE", "4");
						   sortinService.saveShopServ(pd);
						   
					   }else {
						   sortinService.updShopServ(pd);
					   }
					   entertainmentInService.updBar(pd);
				   }
					result = (null==pd.get("CATEGORY_ID"))?"02": "01";
				/*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 *  电商后台获取酒吧，KTV，美食，酒店的品牌和类型
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月6日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getbarndlist")
	@ResponseBody
	public Object getBrandList(){
		logBefore(logger, "电商后台获取酒吧，KTV，美食，酒店的品牌和类型");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETBRANDLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getSortName", pd)){	//检查参数
				   List<PageData>list=new ArrayList<>();
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					   //修改品牌和类型
					   pd.put("SORTNAME", "1");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					 //修改品牌和类型
					   pd.put("SORTNAME", "0");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					 //修改品牌和类型
					   pd.put("SORTNAME", "2");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					 //修改品牌和类型
					   pd.put("SORTNAME", "3");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   }if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_YACHT)){   //入驻分类为游艇
					 //修改品牌和类型
					   pd.put("SORTNAME", "4");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   }if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_LUXCAR)){   //入驻分类为豪车
					 //修改品牌和类型
					   pd.put("SORTNAME", "5");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   }if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HORSE)){   //入驻分类为马术
					 //修改品牌和类型
					   pd.put("SORTNAME", "6");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   }if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_PLANE)){   //入驻分类为飞机
					 //修改品牌和类型
					   pd.put("SORTNAME", "7");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   }if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_GOLF)){   //入驻分类为高尔夫
					 //修改品牌和类型
					   pd.put("SORTNAME", "8");
					   if(pd.get("TYPE").equals("0")){             //0代表查询品牌
						    list = sortinService.getBrandList(pd);  
						}if(pd.get("TYPE").equals("1")) {          //1代表查询类型
							list=sortinService.getStyleList(pd);
						}
				   }
				    map.put("list", list);
					result = (null==pd.get("CATEGORY_ID"))?"02": "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 电商后台酒吧，KTV，美食，酒店添加详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月7日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="entertainmentdetail")
	@ResponseBody
	public Object addEntertainmentDetail(MultipartHttpServletRequest multiReq,HttpServletRequest request,HttpServletResponse response,
			String CATEGORY_ID,String BUSINESS_ID,String FOODDETNAME,String  FOODDETPRICE,String FOODDETREMARK,String HOTELDETNAME,
			String HOTELDETPERNUM,String HOTELDETBREAKFAST,String HOTELDETBATHROOM,String HOTELDETBEDTYPE,String HOTELDETROOMSIZE,
			String HOTELDETROOMNUM,String HOTELDETPRICE,String DETTITLE,String DETTYPE,String DETPRICE,String DETBEGIN,String DETEND,
			String DETNUM
			){
		logBefore(logger, "电商后台酒吧，KTV，美食，酒店添加详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		System.out.println("pd:"+pd);
		String result="00";
		pd.put("CATEGORY_ID", CATEGORY_ID);
		pd.put("BUSINESS_ID", BUSINESS_ID);
		System.out.println("pd1:"+pd);
		try{
			if(Tools.checkKey("ADDENTERTAINMENTDETAIL", pd.getString("FKEY"))){	//检验请求key值是否合法
				//if(AppUtil.checkParam("addProduct", pd)){	//检查参数
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					    pd.put("HOTELDETNAME", HOTELDETNAME);
						pd.put("HOTELDETPERNUM", HOTELDETPERNUM);
						pd.put("HOTELDETBREAKFAST", HOTELDETBREAKFAST);
						pd.put("HOTELDETBATHROOM", HOTELDETBATHROOM);
						pd.put("HOTELDETBREAKFAST", HOTELDETBREAKFAST);
						pd.put("HOTELDETBEDTYPE", HOTELDETBEDTYPE);
						pd.put("HOTELDETROOMSIZE", HOTELDETROOMSIZE);
						pd.put("HOTELDETROOMNUM", HOTELDETROOMNUM);
						pd.put("HOTELDETPRICE", HOTELDETPRICE);
						// 通过工具类上传单个图片
					   String HOTELDETIMGS = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sorthotelimgs/hoteldetimgs");
					   pd.put("HOTELDETAIL_ID", this.getSnowId());
					   pd.put("HOTELDETIMGS", HOTELDETIMGS);
					   pd.put("SORTHOTEL_ID", pd.get("BUSINESS_ID"));
					   sortinService.addHotelDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					    pd.put("FOODDETNAME", FOODDETNAME);
						pd.put("FOODDETPRICE", FOODDETPRICE);
						pd.put("FOODDETREMARK", FOODDETREMARK);
						// 通过工具类上传单个图片
						String FOODDETIMGS = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sortfoodimgs/fooddetimgs");
					   pd.put("FOODDETAIL_ID", this.getSnowId());
					   pd.put("FOODDETIMGS", FOODDETIMGS);
					   pd.put("SORTFOOD_ID", pd.get("BUSINESS_ID"));
					   sortinService.addFoodDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					    pd.put("DETTITLE", DETTITLE);
						pd.put("DETTYPE", DETTYPE);
						pd.put("DETPRICE", DETPRICE);
						pd.put("DETBEGIN", DETBEGIN);
						pd.put("DETEND", DETEND);
						pd.put("DETNUM", DETNUM);
						// 通过工具类上传单个图片
						String KTVDETIMG = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sortktvimgs/ktvdetimgs");
					   pd.put("KTVDETAIL_ID", this.getSnowId());
					   pd.put("KTVDETIMG", KTVDETIMG);
					   pd.put("SORTKTV_ID", pd.get("BUSINESS_ID"));
					   sortinService.addKTVDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					   System.out.println("pd酒吧2:"+pd);
					    pd.put("DETTITLE", DETTITLE);
						pd.put("DETPRICE", DETPRICE);
						pd.put("DETBEGIN", DETBEGIN);
						pd.put("DETEND", DETEND);
						pd.put("DETNUM", DETNUM);
						System.out.println("pd酒吧3:"+pd);
						// 通过工具类上传单个图片
						String BARDETIMG = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sortbarimgs/bardetimgs");
					   pd.put("BARDETAIL_ID", this.getSnowId());
					   pd.put("BARDETIMG", BARDETIMG);
					   pd.put("SORTBAR_ID", pd.get("BUSINESS_ID"));
					   sortinService.addBarDetail(pd);
				   }
					result = (null==pd.get("CATEGORY_ID"))?"02": "01";
				/*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 电商后台获取酒吧，KTV，美食，酒店详情列表
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月7日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getentertainmentdetlist")
	@ResponseBody
	public Object getEntertainmentDetail(){
		logBefore(logger, "电商后台获取酒吧，KTV，美食，酒店详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETENTERTAINMENTDETAIL", pd.getString("FKEY"))){	//检验请求key值是否合法
				//if(AppUtil.checkParam("addProduct", pd)){	//检查参数
				   List<PageData> list =null;
				   List<PageData> temp =new ArrayList<>();
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					    pd.put("SORTHOTEL_ID", pd.get("BUSINESS_ID"));
					    list = sortinService.getHotelDetailList(pd);
						if (list.size()!=0) {
							for (PageData p : list) {
								p.put("BUSINESS_ID", p.get("SORTHOTEL_ID"));
								p.put("DETAIL_ID", p.get("HOTELDETAIL_ID"));
								p.put("CATEGORY_ID", Const.BUSINESS_HOTEL);
								p.remove("SORTHOTEL_ID");
							}
							map.put("pd", list);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					   pd.put("SORTFOOD_ID", pd.get("BUSINESS_ID"));
					   list = sortinService.getFoodDetlist(pd);
						if (list.size()!=0) {
							for (PageData p : list) {
								p.put("BUSINESS_ID", p.get("SORTFOOD_ID"));
								p.put("DETAIL_ID", p.get("FOODDETAIL_ID"));
								p.put("CATEGORY_ID", Const.BUSINESS_HOTEL);
								p.remove("SORTFOOD_ID");
							}
							map.put("pd", list);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					   pd.put("SORTKTV_ID", pd.get("BUSINESS_ID"));
					   list = sortinService.getKTVDetailList(pd);
						if (list.size()!=0) {
							for (PageData p : list) {
								PageData pn=new PageData();
								pn.put("DETAIL_ID", p.get("KTVDETAIL_ID"));
								pn.put("DETTITLE", p.get("KTVDETTITLE"));
								pn.put("DETTYPE", p.get("KTVDETTYPE"));
								pn.put("DETIMG", p.get("KTVDETIMG"));
								pn.put("DETBEGIN", p.get("KTVDETBEGIN"));
								pn.put("DETEND", p.get("KTVDETEND"));
								pn.put("DETNUM", p.get("KTVDETNUM"));
								pn.put("PRICE", p.get("KTVDETPRICE"));
								pn.put("BUSINESS_ID", p.get("SORTKTV_ID"));
								pn.put("CATEGORY_ID", Const.BUSINESS_HOTEL);
								temp.add(pn);
							}
							map.put("pd", temp);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					   pd.put("SORTBAR_ID", pd.get("BUSINESS_ID"));
					   list = sortinService.getBarDetailList(pd);
						if (list.size()!=0) {
							for (PageData p : list) {
								PageData pn=new PageData();
								pn.put("DETAIL_ID", p.get("BARDETAIL_ID"));
								pn.put("DETTITLE", p.get("BARDETTITLE"));
								pn.put("DETIMG", p.get("BARDETIMG"));
								pn.put("DETBEGIN", p.get("BARDETBEGIN"));
								pn.put("DETEND", p.get("BARDETEND"));
								pn.put("DETNUM", p.get("BARDETNUM"));
								pn.put("PRICE", p.get("BARDETPRICE"));
								pn.put("BUSINESS_ID", p.get("SORTBAR_ID"));
								pn.put("CATEGORY_ID", Const.BUSINESS_BAR);
								temp.add(pn);
							}
							map.put("pd", temp);
						}
				   }
					result = (0 == list.size()) ?  "02" :  "01";
				/*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 电商后台根据id获取酒吧，KTV，美食，酒店详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月7日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getentertainmentdet")
	@ResponseBody
	public Object getEntertainmentDet(){
		logBefore(logger, "电商后台根据id获取酒吧，KTV，美食，酒店详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETENTERTAINMENTDET", pd.getString("FKEY"))){	//检验请求key值是否合法
				//if(AppUtil.checkParam("addProduct", pd)){	//检查参数
				       PageData detail =null;
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					    pd.put("SORTHOTEL_ID", pd.get("BUSINESS_ID"));
					     detail = sortinService.getHotelDetail(pd);
					    map.put("detail", detail);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					   pd.put("SORTFOOD_ID", pd.get("BUSINESS_ID"));
					    detail = sortinService.getFoodDetail(pd);
					    map.put("detail", detail);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					   pd.put("SORTKTV_ID", pd.get("BUSINESS_ID"));
					    detail = sortinService.getKTVDetail(pd);
					    map.put("detail", detail);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					   pd.put("SORTBAR_ID", pd.get("BUSINESS_ID"));
					    detail = sortinService.getBarDetail(pd);
					   map.put("detail", detail);
				   }
					result = (null == detail) ?  "02" :  "01";
				/*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 电商后台根据id删除酒吧，KTV，美食，酒店详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月7日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="delentertainmentdet")
	@ResponseBody
	public Object delEntertainmentDet(){
		logBefore(logger, "电商后台根据id删除酒吧，KTV，美食，酒店详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("DELENTERTAINMENTDET", pd.getString("FKEY"))){	//检验请求key值是否合法
				//if(AppUtil.checkParam("addProduct", pd)){	//检查参数
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					   PageData p = sortinService.getHotelDetail(pd);
					   UpdImgUtils.delImgMethod(p, "HOTELDETIMGS", "sortimgs/sorthotelimgs/hoteldetimgs");
				       //UpdImgUtils.delImgMethod(p, "HOTELDETIMGS", "test");
				       sortinService.delHotelDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					   PageData p = sortinService.getFoodDetail(pd);
					   UpdImgUtils.delImgMethod(p, "FOODDETIMGS", "sortimgs/sortfoodimgs/fooddetimgs");
					   //UpdImgUtils.delImgMethod(p, "FOODDETIMGS", "test");
					   sortinService.delFoodDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					   PageData p = sortinService.getKTVDetail(pd);
					   UpdImgUtils.delImgMethod(p, "KTVDETIMG", "sortimgs/sortktvimgs/ktvdetimgs");
					   //UpdImgUtils.delImgMethod(p, "KTVDETIMG", "test");
					   sortinService.delKTVDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					   PageData p = sortinService.getBarDetail(pd);
					   UpdImgUtils.delImgMethod(p, "BARDETIMG", "sortimgs/sortbarimgs/bardetimgs");
					   //UpdImgUtils.delImgMethod(p, "BARDETIMG", "test");
					   sortinService.delBaretail(pd);
				   }
					result =  "01";
				/*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 电商后台酒吧，KTV，美食，酒店修改详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年2月7日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="updentertainmentdetail")
	@ResponseBody
	public Object updEntertainmentDetail(MultipartHttpServletRequest multiReq,HttpServletRequest request,HttpServletResponse response,
			String CATEGORY_ID,String BUSINESS_ID,String FOODDETNAME,String FOODDETPRICE,String FOODDETREMARK,String HOTELDETNAME,
			String HOTELDETPERNUM,String HOTELDETBREAKFAST,String HOTELDETBATHROOM,String HOTELDETBEDTYPE,String HOTELDETROOMSIZE,
			String HOTELDETROOMNUM,String HOTELDETPRICE,String DETTITLE,String DETTYPE,String DETPRICE,String DETBEGIN,String DETEND,
			String DETNUM,String DETAIL_ID
			){
		logBefore(logger, "电商后台酒吧，KTV，美食，酒店修改详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		pd.put("CATEGORY_ID", CATEGORY_ID);
		pd.put("BUSINESS_ID", BUSINESS_ID);
		pd.put("DETAIL_ID", DETAIL_ID);
		String result="00";
		try{
			if(Tools.checkKey("UPDENTERTAINMENTDETAIL", pd.getString("FKEY"))){	//检验请求key值是否合法
				//if(AppUtil.checkParam("addProduct", pd)){	//检查参数
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					    pd.put("HOTELDETNAME", HOTELDETNAME);
						pd.put("HOTELDETPERNUM", HOTELDETPERNUM);
						pd.put("HOTELDETBREAKFAST", HOTELDETBREAKFAST);
						pd.put("HOTELDETBATHROOM", HOTELDETBATHROOM);
						pd.put("HOTELDETBREAKFAST", HOTELDETBREAKFAST);
						pd.put("HOTELDETBEDTYPE", HOTELDETBEDTYPE);
						pd.put("HOTELDETROOMSIZE", HOTELDETROOMSIZE);
						pd.put("HOTELDETROOMNUM", HOTELDETROOMNUM);
						pd.put("HOTELDETPRICE", HOTELDETPRICE);
					// 获取上传文件的路径
						if(multiReq.getFile("file1").isEmpty()){}
						else{
							String HOTELDETIMGS = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sorthotelimgs/hoteldetimgs");
					    	PageData p = sortinService.getHotelDetail(pd);
					    	UpdImgUtils.updImgMethod(p, pd, HOTELDETIMGS, "HOTELDETIMGS", "test");
					    }
					    sortinService.updHotelDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					    pd.put("FOODDETNAME", FOODDETNAME);
						pd.put("FOODDETPRICE", FOODDETPRICE);
						pd.put("FOODDETREMARK", FOODDETREMARK);
					   if(multiReq.getFile("file1").isEmpty()){}
					   else{
						   String FOODDETIMGS = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sortfoodimgs/fooddetimgs");
						   PageData p = sortinService.getFoodDetail(pd);
						   UpdImgUtils.updImgMethod(p, pd, FOODDETIMGS, "FOODDETIMGS", "test");
					   }
					   sortinService.updFoodDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					   if(multiReq.getFile("file1").isEmpty()){}
					   else{
                    	    pd.put("DETTITLE", DETTITLE);
	   						pd.put("DETTYPE", DETTYPE);
	   						pd.put("DETPRICE", DETPRICE);
	   						pd.put("DETBEGIN", DETBEGIN);
	   						pd.put("DETEND", DETEND);
	   						pd.put("DETNUM", DETNUM);
	   					    String KTVDETIMG = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sortktvimgs/ktvdetimgs");
                    	    PageData p = sortinService.getKTVDetail(pd);
                    	    UpdImgUtils.updImgMethod(p, pd, KTVDETIMG, "KTVDETIMG", "test");
					   }
					    sortinService.updKTVDetail(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					    pd.put("DETTITLE", DETTITLE);
						pd.put("DETTYPE", DETTYPE);
						pd.put("DETPRICE", DETPRICE);
						pd.put("DETBEGIN", DETBEGIN);
						pd.put("DETEND", DETEND);
						pd.put("DETNUM", DETNUM);
						if(multiReq.getFile("file1").isEmpty()){}
						else{
							 String BARDETIMG = FTPUtils.upSingleImg(multiReq, "file1", "sortimgs/sortbarimgs/bardetimgs");
                    	     PageData p = sortinService.getBarDetail(pd);
                    	     UpdImgUtils.updImgMethod(p, pd, BARDETIMG, "BARDETIMG", "test");
					    }
					    sortinService.updBarDetail(pd);
				   }
					result = (null==pd.get("CATEGORY_ID"))?"02": "01";
				/*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 后台获取酒吧，KTV，美食，酒店店铺信息
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年3月8日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getentertaininfo")
	@ResponseBody
	public Object getEntertainInfo(){
		logBefore(logger, "后台获取酒吧，KTV，美食，酒店店铺信息");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		List<PageData> shopServ=new ArrayList<>();
		try{
			if(Tools.checkKey("GETENTERTAININFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getCouponListById", pd)){	//检查参数
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HOTEL)){   //入驻分类为酒店
					   PageData p = sortinService.getHotelBusiInfo(pd);
					   ToolsUtil.putImgstoArray(p, "DETAILSIMGS");
					   p.put("CATEGORY_ID", Const.BUSINESS_HOTEL);
					   if(p.get("BRAND")==null){
						   p.put("BRAND", "");
					   }if(p.get("STYLE")==null){
						   p.put("STYLE", "");
					   }
					   shopServ = sortinService.sHotelServ(pd);
					   map.put("shopServ", shopServ);
					   map.put("pd", p);
					   result = (p==null)?"02" : "01";
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_FOOD)){   //入驻分类为美食
					   PageData p = sortinService.getFoodBusiInfo(pd);
					   ToolsUtil.putImgstoArray(p, "DETAILSIMGS");
					   p.put("CATEGORY_ID", Const.BUSINESS_HOTEL);
					   if(p.get("BRAND")==null){
						   p.put("BRAND", "");
					   }if(p.get("STYLE")==null){
						   p.put("STYLE", "");
					   }
					   shopServ = sortinService.sFoodServ(pd);
					   map.put("shopServ", shopServ);
					   map.put("pd", p);
					   result = (p==null)?"02" : "01";
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_KTV)){   //入驻分类为KTV
					   PageData p = sortinService.getKTVBusiInfo(pd);
					   ToolsUtil.putImgstoArray(p, "DETAILSIMGS");
					   p.put("CATEGORY_ID", Const.BUSINESS_HOTEL);
					   if(p.get("BRAND")==null){
						   p.put("BRAND", "");
					   }if(p.get("STYLE")==null){
						   p.put("STYLE", "");
					   }
					   shopServ = sortinService.sKTVServ(pd);
					   map.put("shopServ", shopServ);
					   map.put("pd", p);
					   result = (p==null)?"02" : "01";
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_BAR)){   //入驻分类为酒吧
					   PageData p = sortinService.getBarBusiInfo(pd);
					   ToolsUtil.putImgstoArray(p, "DETAILSIMGS");
					   p.put("CATEGORY_ID", Const.BUSINESS_BAR);
					   if(p.get("BRAND")==null){
						   p.put("BRAND", "");
					   }if(p.get("STYLE")==null){
						   p.put("STYLE", "");
					   }
					   shopServ = sortinService.sBarServ(pd);
					   map.put("shopServ", shopServ);
					   map.put("pd", p);
					   result = (p==null)?"02" : "01";
				   }
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	

}
